package com.taobao.dao.impl;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import com.taobao.dao.CommonDao;
import com.taobao.dao.PreDao;
import com.taobao.pojo.Config;
import com.taobao.pojo.HttpContext;

public class PreDaoImpl extends CommonDao implements PreDao {

    @Override
    public String[] pre(String url) throws Exception {
        return (String[]) this.getRequest(Config.url + url);
    }

    @Override
    public Object process(HttpContext context) throws Exception {
        String[] ve = null;
        Document doc = Jsoup.parse(context.getHtml());

        String vstr = doc.getElementById("__VIEWSTATE").attr("value");
        String estr = doc.getElementById("__EVENTVALIDATION").attr("value");

        ve = new String[2];
        ve[0] = vstr;
        ve[1] = estr;

        return ve;
    }

}
